import UIKit

var str = "Hello, playground"

//不可变数组
let nums = [1,2,3]
let nums1 = [Int](repeating: 6, count: 5)
//可变数组
var munums = [4,3,1,2]
munums.append(5) //添加
//升序
munums.sort()
//降序
munums.sort(by: >)
//将原数组除了最后一个以外的所有元素赋值给另一个数组
let otherNums = Array(munums[0 ..< munums.count - 1])

struct Stack<Element> {
  
    private var stack : [Element]
    var isEmpty: Bool {return stack.isEmpty}
    var peek: AnyObject? { return stack.last as AnyObject? }
    
    init() {
        stack = [Element]()
    }
    
    mutating func push(_ element: Element) {
      stack.append(element)
    }
    
    mutating func pop() -> Element? {
       return stack.popLast()
     }
}

var stack = Stack<String>()
stack.push("2")
stack.push("3")
stack.pop()
